package customer.zspt.cn.customer.Widget.voice;

import android.content.Context;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import customer.zspt.cn.customer.R;

/**
 * Created by Administrator on 2018/8/8 0008.
 */

public class AudioTimeTipView extends LinearLayout {
    private final ImageView fileSize;
    private final LinearLayout recording;
    private final ImageView cancel;
    private final TextView tipText;
    public AudioTimeTipView(Context context) {
        this(context,null);
    }
    public AudioTimeTipView(Context context, @Nullable AttributeSet attrs) {
        this(context, attrs,0);
    }
    public AudioTimeTipView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        View.inflate(context, R.layout.audiotip,this);
        fileSize = (ImageView) findViewById(R.id.fileSize);
        recording = (LinearLayout) findViewById(R.id.recording);
        cancel = (ImageView) findViewById(R.id.cancel);
        tipText = (TextView) findViewById(R.id.tipText);
    }
     /**录音大小的提示*/
       public void setfileSize(double size){
           if(size<=60&&size>0){
               fileSize.setImageResource(R.drawable.v1);
           }
           else if(size<=65&&size>60){
               fileSize.setImageResource(R.drawable.v2);
           }
           else if(size<=70&&size>65){
               fileSize.setImageResource(R.drawable.v3);
           }
           else if(size<=80&&size>70){
               fileSize.setImageResource(R.drawable.v4);
           }
           else if(size<=85&&size>90){
               fileSize.setImageResource(R.drawable.v5);
           }
           else if(size<95&&size>90){
               fileSize.setImageResource(R.drawable.v6);
           }
           else{
               fileSize.setImageResource(R.drawable.v7);
           }
       }
    /**是否取消录音提示*/
       public void cancel(){
           recording.setVisibility(GONE);
           cancel.setBackgroundResource(R.drawable.cancel);
           cancel.setVisibility(VISIBLE);
           tipText.setText("松开手指取消发送");
           tipText.setTextColor(getResources().getColor(R.color.red));
       }
       /**正常录音提示*/
        public void startRecording(){
        recording.setVisibility(VISIBLE);
        cancel.setVisibility(GONE);
        tipText.setText("手指上滑取消发送");
        tipText.setTextColor(getResources().getColor(R.color.white));
    }
    /**录音时间太短的提示*/
     public void OnShortTip(){
         Log.e("short","时间太短");
         recording.setVisibility(GONE);
         cancel.setBackgroundResource(R.drawable.voice_to_short);
         cancel.setVisibility(VISIBLE);
         tipText.setText("录音时间太短");
         tipText.setTextColor(getResources().getColor(R.color.white));
     }
}
